package home

import (
	"net/http"
	"os"
	"path"
	appcommon "go-http-server/common"
)

var wwwRoot string
var staticHandler http.Handler

func InitWWWRoot() {
	wwwRoot = path.Dir(os.Args[0]) + "/" + appcommon.Config.ServerWWWRoot
	staticHandler = http.FileServer(http.Dir(wwwRoot))
}

func Index(w http.ResponseWriter, req *http.Request) {
	if req.URL.RequestURI() == "/favicon.ico" {
		return
	}

	staticHandler.ServeHTTP(w, req)
	//if req.URL.Path != "/" {
	//	staticHandler.ServeHTTP(w, req)
	//	return
	//}

	//fmt.Fprintln(w, "欢迎使用易家健康服务器软件远程运维管理系统")
}
